﻿	<%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core'%>
	<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
	<%@ page import="com.cxx.purchasecharge.component.utils.ComponentConstants" %>

	<script type="text/javascript">
		var editResourceCallback = function() 
		{
			var resource = $('#dg-resource').datagrid('getSelected');
			if(resource) 
			{
				if(resource.enable) 
				{
					$('#dlg-resource #fm-resource #enable')[0].checked = true;
				}
				else 
				{
					$('#dlg-resource #fm-resource #enable')[0].checked = false;
				}
				if(resource.system) 
				{
					$('#dlg-resource #fm-resource #system')[0].checked = true;
				}
				else 
				{
					$('#dlg-resource #fm-resource #system')[0].checked = false;
				}
			}
		}
	</script>

	<table id="dg-resource" title="资源管理" class="easyui-datagrid" url="<c:url value='/resource/getAllResource.html' />"
		toolbar="#toolbar-resource" rownumbers="true" fit="true"
		 singleSelect="true" checkOnSelect="true" selectOnCheck="false"
		fitColumns="true">
		<thead>
			<tr>
				<th data-options="field:'ck',checkbox:true"></th>
				<th data-options="field:'id',hidden:true"></th>
				<th field="name" width="50" sortable="true">资源名</th>
				<th field="value" width="100" sortable="true">资源值</th>
				<th field="enable" width="50" sortable="true" data-options="formatter:cellFormatter_enable, align:'center'">可用</th>
				<th field="system" width="50" sortable="true" data-options="formatter:cellFormatter_enable, align:'center'">系统</th>
				<th field="description" width="100" sortable="false">备注</th>
			</tr>
		</thead>
	</table>
	
	<div id="toolbar-resource">
		<a href="javascript:void(0)" class="easyui-linkbutton" 
			iconCls="icon-add" plain="true" onclick="newModel('#dlg-resource', '新增资源', '#fm-resource', '<c:url value='/resource/newResource.html' />')" title="新增资源">新增资源</a> 
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-edit" plain="true" onclick="editModel('#dg-resource', '#dlg-resource', '编辑资源', '#fm-resource', '<c:url value='/resource/updateResource.html' />', editResourceCallback)" title="<spring:message code="selectOneRow" />编辑资源">编辑资源</a> 
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-remove" plain="true" onclick="destroyMultipleModel('#dg-resource', '资源', '<c:url value='/resource/delResource.html' />')" title="<spring:message code="checkOneOrMultiple" />删除资源">删除资源</a>
	</div>

	<div id="dlg-resource" class="easyui-dialog"
		style="width: 800px; height: 300px; padding: 10px 20px" closed="true"
		buttons="#dlg-buttons-resource" data-options="modal:true">
		<div class="ftitle">资源</div>
		<div style="">
		<form id="fm-resource" class="fm" method="post" novalidate>
			<div class="fitem divHidden">
				<input id="resourceId" name="id" value="0">
			</div>
			<div class="fitem">
				<label>名称:</label> 
				<input name="name" class="easyui-validatebox" required="true"
				validType="myRemote['<c:url value='/resource/checkExist.html' />', 'name', '#resourceId']">
			</div>
			<div class="fitem">
				<label>值:</label> 
				<input name="value" class="easyui-validatebox" required="true" >
			</div>
			<div class="fitem">
				<label>可用:</label> 
				<input id="enable" name="enable" type="checkbox" style="width:20px">
			</div>
			<div class="fitem">
				<label>是否系统:</label> 
				<input id="system" name="system" type="checkbox" style="width:20px">
			</div>
			<div class="fitem">
				<label>备注:</label> 
				<input name="description">
			</div>
		</form>
		</div>
	</div>
	<div id="dlg-buttons-resource">
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-ok" onclick="saveModel('#dg-resource', '#dlg-resource', '#fm-resource')"><spring:message code="save" /></a> 
		<a href="javascript:void(0)" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="javascript:$('#dlg-resource').dialog('close')"><spring:message code="cancel" /></a>
	</div>